﻿using ConfExpert.Forms.Base;
using DevTeam;

using System;
namespace ConfExpert.Forms.Depo.OverProduction
{
    public partial class RFIDManuelOrani : XForm
    {
        public RFIDManuelOrani()
        {
            InitializeComponent();
        }

        private void RFIDManuelOrani_Load(object sender, EventArgs e)
        {
            cmbFormat.EditValueChanged += cmbFormat_EditValueChanged;
            cmbFormat.EditValue = "Ay bazlı";
            gridView1.FocusedRowChanged += gridView1_FocusedRowChanged;
        }

        void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            gridView2.BestFitColumns();
        }

        private void Rfrsh()
        {
            string FK = cmbFormat.EditValue.ToStr().StartsWith("Ay") ? "Ay" : "AtelyeId";

            gridView1.Init("GetRFIDManuelOrani", FK, DBNull.Value);
            gridView1.AddDetailGrid(gridView2, FK);
            gridView1.AddColumn("Toplam", typeof(int), "SUM(Child({FK}).Toplam)");
            gridView1.FormatAsNumber(0, "Toplam");
            gridView2.FormatAsNumber(0, "Toplam");
            gridView1.AddSummary("Toplam");
            gridView2.AddSummary("Toplam");
            gridView1.FormatAsNumber(1, "Oran");
            gridView2.FormatAsNumber(1, "Oran");
            gridView1.SetCaptions("Oran:Manuel Yüzde");
            gridView2.SetCaptions("Oran:Manuel Yüzde");
            gridView1.BestFitColumns();
        }

        void cmbFormat_EditValueChanged(object sender, EventArgs e)
        {
            Rfrsh();
        }
    }
}
